package com.ourchem.web.controller.bus;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ourchem.common.annotation.Log;
import com.ourchem.common.core.controller.BaseController;
import com.ourchem.common.core.domain.AjaxResult;
import com.ourchem.common.enums.BusinessType;
import com.ourchem.bus.domain.CollectManage;
import com.ourchem.bus.service.ICollectManageService;
import com.ourchem.common.utils.poi.ExcelUtil;
import com.ourchem.common.core.page.TableDataInfo;

/**
 * 收藏管理Controller
 * 
 * @author xiYan
 * @date 2023-01-13
 */
@RestController
@RequestMapping("/collect/collect")
public class CollectManageController extends BaseController
{
    @Autowired
    private ICollectManageService collectManageService;

    /**
     * 查询收藏管理列表
     */
//    @PreAuthorize("@ss.hasPermi('collect:collect:list')")
    @GetMapping("/list")
    public TableDataInfo list(CollectManage collectManage)
    {
        startPage();
        List<CollectManage> list = collectManageService.selectCollectManageList(collectManage);
        return getDataTable(list);
    }

    /**
     * 导出收藏管理列表
     */
//    @PreAuthorize("@ss.hasPermi('collect:collect:export')")
    @Log(title = "收藏管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CollectManage collectManage)
    {
        List<CollectManage> list = collectManageService.selectCollectManageList(collectManage);
        ExcelUtil<CollectManage> util = new ExcelUtil<CollectManage>(CollectManage.class);
        return util.exportExcel(list, "收藏管理数据");
    }

    /**
     * 获取收藏管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('collect:collect:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(collectManageService.selectCollectManageById(id));
    }

    /**
     * 新增收藏管理
     */
//    @PreAuthorize("@ss.hasPermi('collect:collect:add')")
    @Log(title = "收藏管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CollectManage collectManage)
    {
        return toAjax(collectManageService.insertCollectManage(collectManage));
    }

    /**
     * 修改收藏管理
     */
//    @PreAuthorize("@ss.hasPermi('collect:collect:edit')")
    @Log(title = "收藏管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CollectManage collectManage)
    {
        return toAjax(collectManageService.updateCollectManage(collectManage));
    }

    /**
     * 删除收藏管理
     */
//    @PreAuthorize("@ss.hasPermi('collect:collect:remove')")
    @Log(title = "收藏管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(collectManageService.deleteCollectManageByIds(ids));
    }
}
